<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ page import="javax.sql.*"%>

<html:html>
<head>
    <title>Start Review Process</title>
    <html:base />
</head>

<body>

<!-- in case validation of the entry data fails in the data bean -->
	<html:errors />
	
	
	
	<%
	RowSet crsCountReviewers = (RowSet) request.getAttribute("crsCountReviewers");
	//<html:link action="/StartReviewAction"> Start review process</html:link>

	crsCountReviewers.next();
	
	Integer countR = crsCountReviewers.getInt("count");
	
	if (countR < 3){
		out.println("<a href=\"/CSE135_Project_struts/cantStartReviewAction.do\"> Start review process</a>");
		out.println("You must provide at least two reviewers before the process is initiated.");
	}else{
		out.println("<a href=\"/CSE135_Project_struts/StartReviewAction.do\"> Start review process </a>");
	}
	%>
	<p>
	<a href="/CSE135_Project_struts/login/invalidate.jsp">Log out.</a>
	<p>
	
	<html:form method="POST" action="/insertReviewer">
		<table border="0">
		
            <tr> 
                <td width="50">
                    Reviewer Username:
                </td>
                <td> 
                    <html:text property ="username" size = "10"/>
                </td>
            </tr>
            <tr> 
                <td width="50">
                    Password:
                </td>
                <td> 
                    <html:password property ="password" size = "10"/>
                </td>
            </tr>
        </table>
        <html:submit value="Add Reviewer"/>
	</html:form>
	<p>
	<b>List of Reviewers:</b>
	<%
	RowSet crsReviewers = (RowSet) request.getAttribute("crsReviewers");
	while(crsReviewers.next()){
	%>
			<html:form action="/deleteReviewer">
					<%=crsReviewers.getString("user_name")%>
				<html:hidden property="id" value="<%=Integer.toString(crsReviewers.getInt(1)) %>" />
				<html:submit value="Delete" /><br>
			</html:form>
		
	<%
	}
	%>
	
	
	


</body>
</html:html>